Goto

Collaborating Authors

 pure function


Learn JAX in 2023: Part 2 - grad, jit, vmap, and pmap

#artificialintelligence

In this tutorial, you will learn the power tools of JAX, grad, jit, vmap, and pmap. To learn how to use JAX's power tools, just keep reading. Welcome to our comprehensive guide on advanced JAX techniques! In the previous tutorial, we were introduced to JAX, and its predecessors autograd and xla. We also briefly looked into numerical computing with JAX. In this post, we'll be diving into some of the most powerful and useful features of the JAX library, including grad, jit, vmap, and pmap. These functions allow you to easily and efficiently compute gradients of functions, optimize your code for faster execution, and apply functions to arrays of data in parallel. By the end of this post, you'll have a solid understanding of how to use these tools to improve the performance and functionality of your numerical computation and machine learning tasks. We'll also cover the topic of randomness in JAX, including how to generate and control random numbers for use in your computations.


Functional RL with Keras and Tensorflow Eager

Robohub

In this blog post, we explore a functional paradigm for implementing reinforcement learning (RL) algorithms. The paradigm will be that developers write the numerics of their algorithm as independent, pure functions, and then use a library to compile them into policies that can be trained at scale. We share how these ideas were implemented in RLlib's policy builder API, eliminating thousands of lines of "glue" code and bringing support for Keras and TensorFlow 2.0. One of the key ideas behind functional programming is that programs can be composed largely of pure functions, i.e., functions whose outputs are entirely determined by their inputs. Here less is more: by imposing restrictions on what functions can do, we gain the ability to more easily reason about and manipulate their execution.


Introduction to Functional Programming in Python

@machinelearnbot

Most of us have been introduced to Python as an object-oriented language; a language exclusively using classes to build our programs. While classes, and objects, are easy to start working with, there are other ways to write your Python code. Languages like Java can make it hard to move away from object-oriented thinking, but Python makes it easy. Given that Python facilitates different approaches to writing code, a logical follow-up question is: what is a different way to write code? While there are several answers to this question, the most common alternative style of writing code is called functional programming.